#!/bin/sh -e

export CPPFLAGS="-DSQLITE_ENABLE_COLUMN_METADATA=1"

clsed 's/ -ltinfo//g' configure

./configure \
    --prefix=/usr \
    --enable-threadsafe \
    --disable-readline \
    --enable-dynamic-extensions \
    --enable-fts5

make
make DESTDIR="$1" install

# Build sqlite manual pages
cd mdoc

./configure
make

mkdir -p "$1/usr/share/man/man3"
./sqlite2mdoc -p "$1/usr/share/man/man3" "$1/usr/include/sqlite3.h"
